package com.esri.core.tasks.geodatabase;

import com.esri.core.internal.util.d;
import java.io.IOException;
import java.io.StringWriter;
import java.util.ArrayList;
import java.util.Iterator;
import org.codehaus.jackson.JsonGenerator;
import org.codehaus.jackson.JsonParser;
import org.codehaus.jackson.JsonToken;

/* loaded from: classes.dex */
public class LayerQueries extends ArrayList<LayerQuery> {
    private static final long serialVersionUID = 1;

    public String toJson() throws IOException {
        StringWriter stringWriter = new StringWriter();
        JsonGenerator a = d.a(stringWriter);
        a.writeStartObject();
        Iterator<LayerQuery> it = iterator();
        while (it.hasNext()) {
            it.next().toJson(a);
        }
        a.writeEndObject();
        a.close();
        return stringWriter.toString();
    }

    public static LayerQueries fromJson(JsonParser jsonParser) throws Exception {
        if (d.c(jsonParser)) {
            LayerQueries layerQueries = new LayerQueries();
            while (jsonParser.nextToken() != JsonToken.END_OBJECT) {
                String currentName = jsonParser.getCurrentName();
                jsonParser.nextToken();
                layerQueries.add(LayerQuery.fromJson(Integer.valueOf(currentName).intValue(), jsonParser));
            }
            return layerQueries;
        }
        return null;
    }
}
